#!/bin/sh
#
# $OpenBSD: kdm.rc,v 1.4 2015/04/13 13:30:02 zhuk Exp $

daemon="${TRUEPREFIX}/bin/kdm"

. /etc/rc.d/rc.subr

rc_reload=NO

# on boot: wait for ttys to be initialized
if [ -n "${INRC}" ]; then
rc_start() {
	( local i=0
	while ! pgrep -qf "^/usr/libexec/getty "; do
		sleep 1
		[ $((i++)) -ge 10 ] && return 1
	done
	# XXX KDM fails to receive input unless getty is given
	# some more time for initialization.
	sleep 2
	${rcexec} "${daemon} ${daemon_flags}" ) &
}
fi

rc_cmd $1
